package com.hydra.core.pojo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * @author:hydra
 * @version 创建时间：2017年11月5日 下午4:44:16 
 * 类说明：用户表
 */
public class User implements Serializable {
	private Long id;// 用户id
	private String username;// 账号
	private String password;// 密码
	private String name;// 名称（昵称或者真实姓名，不同系统不同定义）
	private String salt;// 加密密码的盐
	private byte state;// 用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 1:正常状态,2：用户被锁定.

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public byte getState() {
		return state;
	}

	public void setState(byte state) {
		this.state = state;
	}

	private Set<Role> roles = new HashSet<Role>();

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	/**
	 * 密码盐.
	 * 
	 * @return
	 */
	public String getCredentialsSalt() {
		return this.username + this.salt;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", username=" + username + ", password=" + password + ", name=" + name + ", salt="
				+ salt + ", state=" + state + ", roles=" + roles + "]";
	}

}
